﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sistema_Totem.Presentacion.Presentador.Plantillas;
using Sistema_Totem.Presentacion.Contrato.Plantillas;
using Sistema_Totem.Clases;
using System.Web.SessionState;

namespace Sistema_Totem.Presentacion.Vista.Plantillas
{
    public partial class AgregarPlantillaPasoUno : System.Web.UI.Page, IContratoAgregarPlantillaPasoUno
    {
        private PresentadorAgregarPlantillaPasoUno _presentador;        

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _presentador = new PresentadorAgregarPlantillaPasoUno(this);
            
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            _presentador = new PresentadorAgregarPlantillaPasoUno(this);            
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Sesion["usuario"] == null || (Sesion["usuario"] as Usuario).TipoUsuario != "Administrador")
                Response.Redirect("../Login/login.aspx");
            else
                _presentador.IniciarVista();          
        }

        public HttpSessionState Sesion
        {
            get { return Session; }
        }


        public String NombrePlantilla 
        {
            get { return TextBox1.Text.ToString(); }
            set { }
        }

        public String Descripcion
        {
            get { return TextBox2.Text.ToString(); }
            set { }
        }

        public String Tipo
        {
            get { return DropDownList1.SelectedValue.ToString(); }
            set { DropDownList1.Items.Add(value); }
        }

        public String Estado
        {
            get { return DropDownList2.SelectedValue.ToString(); }
            set { DropDownList2.Items.Add(value); }
        }        

        protected void Button1_Click1(object sender, EventArgs e)
        {
            Session["Plantilla"] = _presentador._Ejecutar();
            Response.Redirect("../Plantillas/AgregarPlantillaPasoDos.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {            
            Button2.CausesValidation = false;
            TextBox1.CausesValidation = false;
            TextBox2.CausesValidation = false;
            RequiredFieldValidator1.Enabled = false;
            RequiredFieldValidator2.Enabled = false;
            Response.Redirect("../../../indexAdmin.aspx");
        }
    }
}